package com.imooc.controller;

import com.imooc.pojo.Orders;
import com.imooc.service.StuService;
import com.imooc.service.center.MyOrdersService;
import com.imooc.utils.IMOOCJSONResult;
import com.sun.java.swing.plaf.windows.resources.windows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;

@Controller
public class BaseController {

    public static final String FOODIE_SHOPCART="shopcart";


    public static final Integer COMMON_PAGE_SIZE=10;
    public static final Integer SEARCH_PAGE_SIZE=20;

    //支付中心的调用地址
    String paymentUrl="http://payment.t.mukewang.com/foodie-payment/payment/createMerchantOrder";

    //微信支付成功 ->支付中心 ->天天吃货平台
    //                      ->回调通知的url
    String payReturnUrl="http://8ia3dt.natappfree.cc/orders/notifyMerchantOrderPaid";


    //用户上传头像的位置
    public static final String IMAGE_USER_FACE_LOCATION= "F:"+File.separator+"JAVA"+File.separator+"tomcat"+File.separator+"apache-tomcat-9.0.34-windows-x64"+File.separator+"apache-tomcat-9.0.34"+File.separator+"webapps"
            +File.separator+"workspaces"+File.separator+"images"+File.separator+"foodie"+File.separator+"faces";



    @Autowired
    public MyOrdersService myOrdersService;
    /**
     *用于验证用户和订单是否有关联关系，避免非法用户调用
     * @return
     */
    public IMOOCJSONResult checkUserOrder(String orderId, String userId){

        Orders orders = myOrdersService.queryMyOrder(orderId, userId);

        if (orders==null){
            return IMOOCJSONResult.errorMsg("订单不存在!");
        }
        return IMOOCJSONResult.ok(orders);
    }
}
